/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.common.client.model;

import com.google.gwt.json.client.JSONObject;

public class AttributeValueModel extends AbstractModel
{
	protected int rowId;
	protected int attributeId;
	protected String attributeName;
	protected int id;
	protected String name;
	protected String prefix;
	protected double price;
	protected String filename;
	protected int maxdays;
	protected int maxcount;
	
	public AttributeValueModel()
	{
		rowId = -1;
		attributeId = -1;
		attributeName = "";
		id = -1;
		name = "";
		price = 0.0;
		prefix = "";
		filename = "";
		maxdays = 0;
		maxcount = 0;
	}
	
	public AttributeValueModel(JSONObject jsonObject)
	{
		rowId = convertToInteger(jsonObject, "row_id");
		attributeId = convertToInteger(jsonObject, "id");
		attributeName = convertToString(jsonObject, "name");
		id = convertToInteger(jsonObject, "values_id");
		name = convertToString(jsonObject, "values_name");
		price = convertToDouble(jsonObject, "values_price");
		prefix = convertToString(jsonObject, "values_price_prefix");
		filename = convertToString(jsonObject, "filename");
		maxdays = convertToInteger(jsonObject, "maxdays");
		maxcount = convertToInteger(jsonObject, "maxcount");
	}

	public void update(AttributeValueModel model)
	{
		rowId = model.getRowId();
		attributeId = model.getAttributeId();
		attributeName = model.getAttributeName();
		id = model.getId();
		name = model.getName();
		price = model.getPrice();
		prefix = model.getPrefix();
		filename = model.getFilename();
		maxdays = model.getMaxDays();
		maxcount = model.getMaxCount();
	}
	
	public int getRowId() {
		return rowId;
	}
	
	public int getAttributeId() {
		return attributeId;
	}
	
	public String getAttributeName() {
		return attributeName;
	}

	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getPrefix() {
		return prefix;
	}

	public double getPrice() {
		return price;
	}

	public String getFilename() {
		return filename;
}

	public int getMaxDays() {
		return maxdays;
	}

	public int getMaxCount() {
		return maxcount;
	}

	public void setMaxDays(int maxdays) {
		this.maxdays = maxdays;
	}

	public void setMaxCount(int maxcount) {
		this.maxcount = maxcount;
	}
}
